package com.hong.chapter3;

/**
 * @Auther: Administrator
 * @Date: 2018/7/17 22:27
 * @Description:
 * 1.类加载器的委托是优先交给父亲加载器先去尝试加载
 * 2.父加载器和子加载其实是一种包装关系，或者包含关系
 */
public class MyClassLoaderTest2 {
    public static void main(String[] args) throws ClassNotFoundException {
        MyClassLoader classLoader1 = new MyClassLoader("MyClassLoader");
        MyClassLoader classLoader2 = new MyClassLoader("MyClassLoader",classLoader1);
        classLoader2.setDir("C:\\Users\\Administrator\\IdeaProjects\\classLoader\\src\\main\\java\\com\\hong\\chapter3\\classloader2");
        Class<?> aClass = classLoader2.loadClass("com.hong.chapter3.myObject");
        System.out.println(aClass.hashCode());
        System.out.println(aClass);
        Class<?> aClass2 = classLoader2.loadClass("com.hong.chapter3.myObject");
        System.out.println(aClass2.hashCode());
        System.out.println(((MyClassLoader)aClass.getClassLoader()).getClassLoaderName());
    }
}
